home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 23 / CU Amiga - Super CD-ROM 23 (June 1998).iso / CUCD / Programming / OUI / rcs / string.cc < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  5.6 KB  |  265 lines

  1. head    1.4;
  2. access;
  3. symbols;
  4. locks
  5.     dlorre:1.4; strict;
  6. comment    @// @;
  7.  
  8.  
  9. 1.4
  10. date    98.01.13.20.02.05;    author dlorre;    state Exp;
  11. branches;
  12. next    1.3;
  13.  
  14. 1.3
  15. date    97.07.14.04.20.15;    author dlorre;    state Exp;
  16. branches;
  17. next    1.2;
  18.  
  19. 1.2
  20. date    96.08.28.20.06.02;    author dlorre;    state Exp;
  21. branches;
  22. next    1.1;
  23.  
  24. 1.1
  25. date    96.08.22.02.05.10;    author dlorre;    state Exp;
  26. branches;
  27. next    ;
  28.  
  29.  
  30. desc
  31. @Oui.lib -- Object User Interface
  32. Projet créé en 1994
  33. Auteur: Dominique Lorre
  34. @
  35.  
  36.  
  37. 1.4
  38. log
  39. @changed colors and box
  40. @
  41. text
  42. @// $Id: string.cc 1.3 1997/07/14 04:20:15 dlorre Exp dlorre $
  43. #include <exec/lists.h>
  44. #include <intuition/imageclass.h>
  45. #include <intuition/gadgetclass.h>
  46. #include <libraries/gadtools.h>
  47. #include <string.h>
  48. #include <mydebug.h>
  49.  
  50. #include <proto/dos.h>
  51. #include <proto/intuition.h>
  52.  
  53. #include "gadgets/string.h"
  54. #include "gadgetlist.h"
  55. #include "window.h"
  56. #include "screen.h"
  57.  
  58.  
  59. // ========================================================================
  60. // ==========================  STRING CLASS ===============================
  61. // ========================================================================
  62.  
  63. string::string(gadgetlist *gl,
  64.                void (window::*func)(gadget *, unsigned long, unsigned short),
  65.                const char *title,
  66.                const char *text,
  67.                long max,
  68.                unsigned long flags,
  69.                unsigned long justify) : gadget(gl, func), maxsize(max)
  70. {
  71. long pens, apens ;
  72.  
  73.     pens =  gl->win->ws->xpens[BLACK_PEN] << 8 ;
  74.     apens = gl->win->ws->xpens[WHITE_PEN] << 8 ;
  75.     pens += gl->win->ws->xpens[WHITE_PEN] ;
  76.     apens += gl->win->ws->xpens[BLACK_PEN] ;
  77.     gl->ng->ng_GadgetText = (UBYTE *)title ;
  78.     underkey(title) ;
  79.     gl->ng->ng_Flags = flags ;
  80.  
  81.     // since the font style can be modified several times
  82.     // in a window opening process, this is a reliable way to be sure
  83.     // that the wanted font will be used
  84.  
  85.     gfont = OpenFont(gl->ng->ng_TextAttr) ;
  86.  
  87.     im = (Image *)NewObject(NULL, (UBYTE *)"frameiclass",
  88.         IA_Top,             -2,
  89.         IA_Left,            -3,
  90.         IA_Width,           gl->ng->ng_Width+6,
  91.         IA_Height,          gl->ng->ng_Height+4,
  92.         IA_Recessed,        FALSE,
  93.         IA_EdgesOnly,       TRUE,
  94.         IA_FrameType,       FRAME_RIDGE,
  95.         TAG_DONE) ;
  96.  
  97.     buffer = new char[max+1] ;
  98.  
  99.     gad = gl->gad = (Gadget *)NewObject(NULL, (UBYTE *)"strgclass",
  100.             GA_Top,                 gl->ng->ng_TopEdge,
  101.             GA_Left,                gl->ng->ng_LeftEdge,
  102.             GA_Width,               gl->ng->ng_Width,
  103.             GA_Height,              gl->ng->ng_Height,
  104.             GA_ID,                  id,
  105.             GA_Image,               im,
  106.  
  107.             GA_RelVerify,           TRUE,
  108.  
  109.             GA_Previous,            gl->gad,
  110.             GA_TabCycle,            TRUE,
  111.  
  112.             STRINGA_MaxChars,       max,
  113.             text?STRINGA_TextVal:TAG_IGNORE,        text,
  114.             STRINGA_Pens,           pens,
  115.             STRINGA_ActivePens,     apens,
  116.             STRINGA_Justification,  justify,
  117.             STRINGA_Buffer,         buffer,
  118.             STRINGA_Font,           gfont,
  119.             TAG_END) ;
  120.  
  121.     curstring = new char[max+1] ;
  122.     strcpy(curstring, buffer) ;
  123. }
  124.  
  125. string::~string()
  126. {
  127.     if (gad) DisposeObject(gad) ;
  128.     if (im) DisposeObject(im) ;
  129.     if (buffer) delete buffer ;
  130.     if (curstring) delete curstring ;
  131.     if (gfont) CloseFont(gfont) ;
  132. }
  133.  
  134. void string::action(unsigned long classe, unsigned short code)
  135. {
  136. LONG l = strlen(buffer) ;
  137.  
  138.     if (maxsize < l) {
  139.         maxsize = l ;
  140.         delete curstring ;
  141.         curstring = new char[maxsize+1] ;
  142.     }
  143.     strcpy(curstring, buffer) ;
  144.     gadget::action(classe, code) ;
  145. }
  146.  
  147. void string::set(STRPTR text)
  148. {
  149. LONG l = strlen(text) ;
  150.  
  151.     if (maxsize < l) {
  152.         maxsize = l ;
  153.         delete curstring ;
  154.         curstring = new char[maxsize+1] ;
  155.     }
  156.     strcpy(curstring, text) ;
  157.     SetGadgetAttrs(gad, w, NULL,
  158.         STRINGA_TextVal,    text,
  159.         TAG_END) ;
  160. }
  161.  
  162. void string::keystroke(BOOL shifted)
  163. {
  164.     ActivateGadget(gad, w, NULL) ;
  165. }
  166.  
  167. @
  168.  
  169.  
  170. 1.3
  171. log
  172. @*** empty log message ***
  173. @
  174. text
  175. @d1 1
  176. a1 1
  177. // $Id: string.cc 1.2 1996/08/28 20:06:02 dlorre Exp dlorre $
  178. d32 2
  179. a33 1
  180.     pens = apens = gl->win->ws->xpens[BLACK_PEN] << 8 ;
  181. d35 1
  182. a35 2
  183.     apens += gl->win->ws->xpens[GREEN_PEN] ;
  184.  
  185. d47 4
  186. a50 4
  187.         IA_Top,             -1,
  188.         IA_Left,            -2,
  189.         IA_Width,           gl->ng->ng_Width+4,
  190.         IA_Height,          gl->ng->ng_Height+2,
  191. d59 4
  192. a62 4
  193.             GA_Top,                 gl->ng->ng_TopEdge+1,
  194.             GA_Left,                gl->ng->ng_LeftEdge+2,
  195.             GA_Width,               gl->ng->ng_Width-4,
  196.             GA_Height,              gl->ng->ng_Height-2,
  197. @
  198.  
  199.  
  200. 1.2
  201. log
  202. @bug corrigé : affichage des pens
  203. @
  204. text
  205. @d1 1
  206. a1 1
  207. // $Id$
  208. d7 1
  209. d9 2
  210. a10 3
  211. #include <cxxproto/dos.h>
  212. #include <cxxproto/intuition.h>
  213. #include <cclib/debug_protos.h>
  214. d24 2
  215. a25 2
  216.                STRPTR title,
  217.                STRPTR text,
  218. d28 1
  219. a28 1
  220.                unsigned long justify) : gadget(gl, func)
  221. d36 1
  222. a36 1
  223.     gl->ng->ng_GadgetText = title ;
  224. d40 7
  225. a46 1
  226.     im = (Image *)NewObject(NULL, "frameiclass",
  227. d49 3
  228. a51 3
  229.         IA_Width,           gl->ng->ng_Width,
  230.         IA_Height,          gl->ng->ng_Height,
  231.         IA_Recessed,        TRUE,
  232. d53 1
  233. d56 3
  234. a58 1
  235.     gad = gl->gad = (Gadget *)NewObject(NULL, "strgclass",
  236. d76 2
  237. a77 1
  238.  
  239. d81 1
  240. a81 1
  241.     strcpy(curstring, (STRPTR)((StringInfo *)gad->SpecialInfo)->Buffer) ;
  242. d88 1
  243. d90 1
  244. d95 8
  245. a102 1
  246.     strcpy(curstring, (STRPTR)((StringInfo *)gad->SpecialInfo)->Buffer) ;
  247. d108 7
  248. @
  249.  
  250.  
  251. 1.1
  252. log
  253. @Initial revision
  254. @
  255. text
  256. @d1 1
  257. d32 1
  258. a32 1
  259.     pens = apens = gl->win->ws->xpens[BLACK_PEN] << 4 ;
  260. a35 2
  261.  
  262.  
  263. d46 1
  264. @
  265.